package com.ww.springboot.es2.controller;

import com.ww.springboot.es2.app.search.service.IEsSearchToolSvc;
import com.ww.springboot.es2.dto.EsQueryDTO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * es消息-》controller
 *
 * @author wanwei
 * @since 2021-01-26 11:10
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("es")
public class EsController {

    private final IEsSearchToolSvc esSearchToolSvc;


    @PostMapping("/exportWithApi")
    public void exportWithApi(HttpServletResponse response, @RequestBody EsQueryDTO esQueryDTO) throws IOException {
        esSearchToolSvc.exportWithApi(response, esQueryDTO);
    }

    @PostMapping("/exportWithApiAndScroll")
    public void exportWithApiAndScroll(HttpServletResponse response, @RequestBody EsQueryDTO esQueryDTO) throws IOException {
        esSearchToolSvc.exportWithApiAndScroll(response, esQueryDTO);
    }
}
